package org.linja.oauth4j.impl;

import java.util.Arrays;
import java.util.List;

import org.oauth4j.core.OAuth4JService.Method;
import org.oauth4j.core.OAuth4JService.Protocol;
import org.oauth4j.core.OAuth4JServiceProvider;
import org.oauth4j.core.OAuth4JServiceProviderService;
import org.oauth4j.core.SimpleOAuth4JSPService;

public class LinkedInSP implements OAuth4JServiceProvider {
    private static final String requestToken = "https://api.linkedin.com/uas/oauth/requestToken";
    private static final String authorize = "https://api.linkedin.com/uas/oauth/authorize";
    private static final String accessToken = "https://api.linkedin.com/uas/oauth/accessToken";

    @Override
    public OAuth4JServiceProviderService getRequestTokenEndpoint() {
	return new SimpleOAuth4JSPService(Protocol.HTTPS, Method.GET,
	        requestToken, String.class, 0);
    }

    @Override
    public OAuth4JServiceProviderService getAuthorizeTokenEndpoint() {
	return new SimpleOAuth4JSPService(Protocol.HTTPS, Method.GET,
	        authorize, String.class, 0);
    }

    @Override
    public OAuth4JServiceProviderService getAccessTokenEndpoint() {
	return new SimpleOAuth4JSPService(Protocol.HTTPS, Method.GET,
	        accessToken, String.class, 0);
    }

    @Override
    public <S extends OAuth4JServiceProviderService> List<S> getServices() {
	List<LinkedInSPServices> list = Arrays.asList(LinkedInSPServices
	        .values());
	return (List<S>) list;
    }

}
